<?php
/*-------------------------------------------------------------------------\
|
|  ========================================================
|  Fusion Registry GPL
|  Copyright (C) 2007 Fusion Scripts
|
|  This program is free software; you can redistribute it and/or
|  modify it under the terms of the GNU General Public License
|  as published by the Free Software Foundation; either version 2
|  of the License, or (at your option) any later version.
|
|  This program is distributed in the hope that it will be useful,
|  but WITHOUT ANY WARRANTY; without even the implied warranty of
|  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
|  GNU General Public License for more details.
|
|  You should have received a copy of the GNU General Public License
|  along with this program; if not, write to the Free Software
|  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
|  ========================================================
|
|  Email: info@fusionscripts.com
|  Web-Site: http://www.fusionscripts.com/
|
|  $Id: registry.php 4 2008-08-03 01:43:03Z registry.fusion $
|
\-------------------------------------------------------------------------*/

/**
 * This is the admin interface for all the admin files of the Fusion Registry
 *
 * @package Fusion Registry
 * @subpackage admin
 * @version $Id: registry.php 4 2008-08-03 01:43:03Z registry.fusion $
 */

/**
 * Configuration file for the registry
 */
require( ROOT_PATH.'sources/components_public/fusion_config.php' );

/**
 * Class 'ad_registry' is the ACP interface for all the admin files
 *
 * If you are changing the URL to the registry you need to change the class
 * name in this file. Change 'class ad_registry' to reflect the new name.
 * For example if you choose 'tracker' change this to 'class ad_tracker'.
 *
 * @package Fusion Registry
 * @subpackage admin
 */
class ad_registry
{
    var $ipsclass;
    var $base_url;

    function auto_run()
    {
        $tmp_in = array_merge( $_GET, $_POST, $_COOKIE );

        foreach ( $tmp_in as $k => $v )
        {
            unset($$k);
        }

        if ( ! @is_dir( AD_REGISTRY_PATH ) )
        {
            print "<h1>Installation not found!</h1>Please ensure you have fully installed the Fusion Registry.";
            exit();
        }
        else
        {
            // Define valid admin classes
            $valid_classes = array( 'categories', 'config', 'custom_fields', 'makes_models', 'permissions', 'rating_fields', 'tools' );

            // Only valid classes will make it through
            if ( in_array($this->ipsclass->input['menu'], $valid_classes) )
            {
                $ad_menu = "ad_{$this->ipsclass->input['menu']}";
                $ad_class = "ad_registry_{$this->ipsclass->input['menu']}";

                /**
                 * This is used to ensure that direct access to the admin files can not be achieved
                 *
                 * Any admin module should verify that this constant is set, and if not bomb out!
                 */
                define( 'AD_REGISTRY_CALLED', 1 );

                require( AD_REGISTRY_PATH. $ad_menu .'.php' );
                
                $ad_object = new $ad_class();
                $ad_object->ipsclass =& $this->ipsclass;
                $ad_object->auto_run();
            }
            else
            {
                print "<h1>Invalid access!</h1>You many not access unauthorized administration classes!";
                exit();
            }
        }
    }
}

?>